<?php
/**
*
* @package {PACKAGENAME}
* @version $Id: $
* @copyright (c) 2008 Alejandro Darío Simi
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
include 'config.php';
include "functions.$phpEx";
include "ForumTools.$phpEx";
include "Params.$phpEx";

connect_database();

$sitename = ForumTools::sitename();
$sitedesc = ForumTools::description();
$sitelink = ForumTools::link();													?>
<?='<?'?>xml version="1.0" encoding="UTF-8"<?='?>'?>

<rss version="2.0">
	<channel>
		<title><?=$sitename?> (Lasts Posts)</title>
		<link><?=$sitelink?></link>
		<description><?=$sitedesc?></description>
		<category>Last Posts</category>
<?php
$sql = "SELECT	{$table_prefix}posts.*,
				{$table_prefix}forums.forum_name,
				{$table_prefix}users.user_avatar
		FROM	{$table_prefix}posts,
				{$table_prefix}forums,
				{$table_prefix}users
		WHERE	{$table_prefix}posts.forum_id  = {$table_prefix}forums.forum_id
		 AND	{$table_prefix}posts.poster_id = {$table_prefix}users.user_id
		ORDER BY {$table_prefix}posts.post_time DESC";
$res = $db->sql_query_limit($sql, $postsLimitOnRSS);

while ($row = $db->sql_fetchrow($res))
{
	if (!ForumTools::is_private($row['forum_id'], $row['topic_id']) && (
			!ForumTools::is_protected($row['forum_id'], $row['topic_id']) || Params::show_protected()))
	{																			?>
		<item>
			<title><?=$row['post_subject']?></title>
			<link><?=ForumTools::adapt_string("{$sitelink}/viewtopic.php?f={$row['forum_id']}&t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}")?></link>
			<description><?=ForumTools::adapt_string($row, true)?></description>
			<category><?=$row['forum_name']?></category>
<?php	if ($row['user_avatar'])
		{																		?>
			<image><?=$row['user_avatar']?></image>
<?php	}																		?>
		</item>
<?php
	}
}

$db->sql_freeresult($res);														?>
	</channel>
</rss>